package org.fuxian.web.interceptor;

import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

public class PowerValidateInterceptor extends HandlerInterceptorAdapter {
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse
            response, Object handler)
            throws Exception {
        System.out.println("......"+request.getRequestURL().toString());
        HttpSession session = request.getSession();
        Object user = session.getAttribute("LOGIN_USER");
        if(user!=null){
            return super.preHandle(request, response, handler);
        }else {
            response.sendRedirect(request.getContextPath() + "/index.jsp");
            return false;
        }

    } }